home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / tex / rexx / ttx / start_tex.ttx < prev    next >
Text File  |  1991-11-15  |  3KB  |  129 lines

  1. /*RX
  2.  * AREXX    Name:Start_TeX.ttx    Version:1.5JS    Date:15-Nov-91
  3.  *
  4.  
  5. CED-File changed by Jan Schroeder for use with TTX.
  6.  
  7.  This AREXX script saves and compiles the current TTX view. The only
  8. (optional) argument is the format to be used. A '?' formatname will
  9. interactively ask for the format to use.
  10.  *
  11.  A command is send to the TeX server to compile the file. Hence a
  12. return value of 0 does not mean that the file compiled well, but only
  13. that the command was sent to the server and replied to.
  14.  *
  15. AUTHOR:
  16.  *    J\"org H\"ohle, March 91
  17.  *
  18. BUGS:
  19.  virtex doesn't like filenames with blanks (and ARexx parses them
  20. hardly too), so avoid them in file, directory *and* device names.
  21.  *
  22.  Does not like names relative to the local root, like ":foo/bar"
  23.  *
  24. FILES:
  25.  ENV:TEXFORMAT: default format used
  26.  REXX:namestruc
  27.  *
  28.  */
  29.  
  30. /* OPTIONS FAILAT 3 */
  31.  
  32. /*
  33.  * IF ~SHOW('L','rexxsupport.library') THEN
  34.  *     IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN DO
  35.  *         okay1 "Can't open 'rexxsupport.library'!"
  36.  *         EXIT 20
  37.  *         END
  38.  */
  39.  
  40. OPTIONS RESULTS
  41.  
  42. portname = 'Start_TeX'
  43. script     = 'TeX-server.rexx'    /* no path required, message only    */
  44.  
  45. IF "" = GETCLIP("TEXQUERY") THEN askformat = 0
  46. ELSE askformat = 1        /* ask interactively for format name    */
  47.  
  48. PARSE ARG format .
  49. IF "?" = format THEN DO
  50.     askformat= 1
  51.     format     = ""
  52.     END
  53. ELSE IF '&' = LEFT(format,1) THEN
  54.     format = SUBSTR(format,2)
  55.  
  56. GetFilePath    /* full filename */
  57. fullname=RESULT
  58.  
  59. /* We need an absolute name */
  60. PARSE VALUE namestruc(fullname) WITH ivol idirs ibase .
  61.  
  62. IF "" == SUBSTR(fullname, 1+ivol+idirs+ibase) | UPPER(RIGHT(fullname,3)) ~= "TEX" THEN DO
  63.     SetStatusBar "Sorry, filename must end in `tex'."
  64.     EXIT
  65.     END
  66.  
  67. IF 0 = ivol THEN DO
  68.     direc = PRAGMA('d')
  69.     IF RIGHT(direc,1)~='/' & RIGHT(direc,1)~=':' THEN direc=direc||'/'
  70.     fullname = direc||fullname
  71.     DROP direc
  72.     END
  73. DROP ivol idirs ibase
  74.  
  75. /* Save only if file has been modified */
  76. GetFileInfo
  77. PARSE VALUE RESULT WITH iline imod iname .
  78. If UPPER(imod) == "YES" THEN SaveFile
  79.  
  80. IF (SHOW('P', portname)) THEN DO
  81.     /* set the default format, modify it to suit your needs */
  82.     envformat = mygetenv("TEXFORMAT")
  83.     IF "" == format THEN DO
  84.         format = envformat
  85.         IF askformat | "" = envformat THEN DO
  86.         IF "" = format THEN format = 'glplain'
  87.  
  88.         dum = RESULT
  89.         RequestStr PROMPT Format? glplain
  90.         nformat=RESULT
  91.         /* if cancelled */
  92.          IF dum ~= nformat THEN format = nformat
  93.  
  94.         END /* askformat */
  95.         END /* format */
  96.  
  97.     /* If the server is already busy with some compilation, this will
  98.     wait till compilation finishes, this may take a long time */
  99.  
  100.     if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
  101.  
  102.     ADDRESS VALUE portname
  103.     'compile' format fullname
  104.     END
  105. ELSE DO
  106.     SetStatusBar "The TeX server 'script' is not running !"
  107.     EXIT
  108.     END
  109. EXIT
  110.  
  111.  
  112. mygetenv: procedure    /* when will ARexx supply GetEnv/SetEnv ? */
  113.    PARSE ARG name
  114.  
  115.    IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
  116.     gives = readln(TEMPFILE)
  117.     CALL close TEMPFILE
  118.     END
  119.    ELSE gives = ""
  120.  
  121.    RETURN gives
  122.  
  123. mysetenv: procedure
  124.    PARSE ARG name,content
  125.  
  126.    ADDRESS COMMAND "SetEnv" name content
  127.  
  128.    RETURN
  129.